import KoaRouter from 'koa-router'
import Mock from 'mockjs'

/**
 * AQI信息
 */
export interface IAqi {
  aqi: number
  gas: string
}

/**
 * AQI接口
 */
export interface IApiGetAqi {
  data?: IAqi
}

const router = new KoaRouter()

/**
 * @api {get} /aqi 获取AQI信息
 * @apiName getAQI
 * @apiGroup AQI
 * @apiDescription 获取AQI信息
 *
 * @apiSuccessExample {json} 获取成功
 *   HTTP/1.1 200 OK
 *   {
 *     "data": {
 *       "aqi": 1,
 *       "gas": "pm10"
 *     }
 *   }
 *
 * @apiSuccess {Object} data AQI数据
 * @apiSuccess {Number} data.aqi 当前的AQI数值
 * @apiSuccess {String} data.gas 首要污染物
 */
router.get('getAQI', '/', ctx => {
  ctx.body = Mock.mock({
    data: {
      'aqi|0-500': 1,
      'gas|1': ['pm2.5', 'pm10'],
    },
  })
})

export default router.routes()
